<template>
  <div id="app">
    <!--    <div id="nav">-->
    <!--      <router-link to="/">Home</router-link> |-->
    <!--      <router-link to="/about">About</router-link> |-->
    <!--      <router-link to="/player">Player</router-link>-->
    <!--    </div>-->
    <!--    <router-view />-->

    <el-container>
      <el-header class="header-box">
        <el-row>
          <el-col :span="2" :offset="0">
            <img
              class="company-logo"
              src="@/assets/comlogo.jpeg"
              alt="图片未找到"
            /></el-col>
          <el-col :span="2" class="intro"><span>超市会员</span></el-col>
          <el-col :span="2" :offset="18" class="user-config">
            <el-dropdown trigger="click" @command="switchMenu"
            >
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="personalMessage"
                >个人资料</el-dropdown-item
                >
                <el-dropdown-item command="modifyPwd"
                >修改密码</el-dropdown-item
                >
                <el-dropdown-item>注销</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </el-col>
        </el-row>
      </el-header>
      <el-container>
        <el-aside width="220px">
          <el-menu
            router
            :default-active="$route.path"
            unique-opened
            background-color="#001529"
            text-color="2c3e50"
          >
            <el-menu-item index="/">
              <template slot="title">
                <span class="nav-text">主页</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/about">
              <template slot="title">
                <span class="nav-text">关于</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/player">
              <template slot="title">
                <span class="nav-text">人物信息</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/dealBill">
              <template slot="title">
                <span class="nav-text">交易信息</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/book">
              <template slot="title">
                <span class="nav-text">图书信息</span>
              </template>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
// import New from './components/New.vue';
export default {
  name: "App",
  components: {
    // New,Old,
  },
  props: {
    sampleP: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      sampleD: "value",
    };
  },
  computed: {
    // sampleC() {
    //     return this.sampleD+'--';
    // }
  },

  created() {
    // this.initProfessionTypes();
    // this.$store.actions.getProfessionTypes();
    this.$store.dispatch("getProfessionTypes");
    this.$store.dispatch("getDealStates");
  },
  mounted() {
    // document.querySelector("body").setAttribute("style",
    //   "margin:0;padding:0")
  },
  methods: {
    sampleM(cmd) {
      this.$message.warning("abc" + JSON.stringify(cmd));
    },
    switchMenu(cmd) {
      if (cmd) {
        switch (cmd) {
          case "personalMessage":
            this.personalMessage();
            break;
          case "modifyPwd":
            this.modifyPwd("zhangsan");
            break;
          default:
            this.sampleM();
        }
      }
    },
    personalMessage() {
      this.$message.success("个人资料展");
    },
    modifyPwd(username) {
      this.$message.success("将要修改此密码" + username);
    },

    // initProfessionTypes(){
    /*    this.$http({
              method: "get",
              url: "/ceto/common/professionTypes",
            }).then(
              (res) => {
                // this.$message.warning(JSON.stringify(res.data));
               console.log(this.$store.state.professionTypes);
               // this.$store.mutations.updateProfessionTypes(state,payload)
               //    this.$store.commit("updateProfessionTypes",payload)
                this.$store.commit("updateProfessionTypes",res.data)
              },
              (error) => {
                console.log(" request error : "+error.response.status);
              }
            );*/
    // }
  },
  watch: {
    // sampleC(newValue, oldValue) {
    //
    // }
  },
};
</script>
<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
$headerHeight: 50px;
.header-box {
  height: $headerHeight;
  background-color: #001529;
  padding: 0;
  line-height: -10px;
  span {
    //background-color: rgba(216,55,23,0.44);
    color: aliceblue;
  }
}
.el-aside {
  //background-color: rgba(216,136,215,0.62);
  min-height: 700px;
}
.el-main {
  //background-color: rgba(216,125,126,0.62);
}
.nav-text {
  color: azure;
}
.el-menu {
  min-height: calc(100vh - #{$headerHeight});
}
.company-logo {
  height: $headerHeight;
  border-radius: 10px;
}
.intro {
  margin-top: 10px;
  margin-left: -38px;
  font-size: 26px;
}
.user-config {
  margin-top: 10px;
  font-size: 20px;
}
</style>
